<?php
    require("./include.php");
	
	if($_SESSION[user_id]){
		?>
		<script>
			alert("로그인한 상태입니다");
			history.back();
		</script>
		<?
	}
	
	if($_POST[m_id] == ""){
		?>
		<script>
			alert("아이디를 입력하세요");
			history.back();
		</script>
		<?
		exit;
	}
	
	if($_POST[m_pass] == ""){
		?>
		<script>
			alert("비밀번호를 입력하세요");
			history.back();
		</script>
		<?
		exit;
	}
	
	$chk_sql = "select * from tb_member where m_id = '".trim($_POST[m_id])."'";
	$chk_result = sql_querry($chk_sql);
	$chk_data = mysql_fetch_array($chk_result);
	
	if($chk_data[m_idx]){
		
		if($_POST[m_pass] == $chk_data[m_pass]){
			$_SESSION[user_idx] = $chk_data[m_idx];
			$_SESSION[user_id] = $chk_data[m_id];
			$_SESSION[user_name] = $chk_data[m_name];
			?>
			<script>
				alert("환영합니다");
				location.replace("board_list.php");
			</script>
			<?
			exit;
		}else{
			?>
			<script>
				alert("비밀번호를 확인하세요");
				history.back();
			</script>
			<?
			exit;
		}
	}else{
		?>
		<script>
			alert("존재하지 않는 회원입니다");
			history.back();
		</script>
		<?
		exit;
	}
?>